<?php 

class Log_amount_model extends Model {
	 
   /**
	* Constructor 
	*
	*/
	function Log_amount_model() 
	{
	  	parent::Model();
    }//Controller End
	  
	// --------------------------------------------------------------------
		
	/**
	 * Add log point
	 *
	 * @access	private
	 * @param	array	an associative array of insert values
	 * @return	void
	 */
	 function addLogAmount($insertData=array())
	 {
	 	return $this->db->insert('log_amount', $insertData);
		 
	 }//End of addTransaction Function
	
	 /**
	  * Update log amount
	  *
	  * @access	private
	  * @param	array	an associative array of insert values
	  * @return	void
	  */
	 function updateLogAmount($updateKey=array(),$updateData=array())
	 {
	 	return $this->db->update('log_amount',$updateData,$updateKey);
	 		
	 }//End of editGroup Function

	/**
	 * Get log amount
	 *
	 * @access	private
	 * @param	array	conditions to fetch data
	 * @return	object	object with result set
	 */
	 function getLogAmount($conditions=array(),$fields='',$like=array(),$limit=array(),$order=array())
	 {
	 	if(count($conditions)>0)		
	 		$this->db->where($conditions);
		
		if(is_array($like) and count($like)>0)
			$this->db->like($like);	
		
		//Check For Limit	
		if(is_array($limit))		
		{
			if(count($limit)==1)
	 			$this->db->limit($limit[0]);
			else if(count($limit)==2)
				$this->db->limit($limit[0],$limit[1]);
		}
		
		if(is_array($order) and count($order)>0)			
		   $this->db->orderby($order[0],$order[1]);
		else   
		   $this->db->orderby('created','desc');	
		
		$this->db->from('log_amount');
		$this->db->join('users', 'users.id = log_amount.user_id','inner');
		
		//Check For Fields	 
		if($fields!='')
			$this->db->select($fields);
		else 	
	 		$this->db->select('log_amount.id,log_amount.status,log_amount.score,log_amount.balance,log_amount.created,log_amount.user_id,users.user_name');
			
		$result = $this->db->get();
		return $result;
	 }
	 
}
